﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.CApDduCommandParamsUtils
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using COMMANDPARAMSLib;
using EngineeringInternalExtension;
using System.Collections.ObjectModel;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.CommandParameters;


namespace DnProcessSimulateCommands;

internal class CApDduCommandParamsUtils
{
  internal static TxMultipleObjectParameters GetMultiObjectParameters(object cmdParams)
  {
    switch (cmdParams)
    {
      case ICoMultipleObjectParams multipleObjectParams:
        pattern_0 = new TxMultipleObjectParameters();
        TxObjectList txObjectList1 = new TxObjectList();
        ITApiObjCollection ppObjs = (ITApiObjCollection) null;
        multipleObjectParams.GetObjList(ref ppObjs);
        TxObjectList txObjectList2 = CApDduCommandParamsUtils.ConvertApiObjCollToTxObjectList(ppObjs);
        pattern_0.Objects = txObjectList2;
        break;
    }
    return pattern_0;
  }

  private static TxObjectList ConvertApiObjCollToTxObjectList(ITApiObjCollection ppObjs)
  {
    TxObjectList txObjectList = new TxObjectList();
    if (ppObjs != null)
    {
      foreach (ITApiObj ppObj in ppObjs)
      {
        ITxObject objectFromApiObj = CApDduCommandParamsUtils.GetObjectFromApiObj(ppObj);
        if (objectFromApiObj != null)
          ((Collection<ITxObject>) txObjectList).Add(objectFromApiObj);
      }
    }
    return txObjectList;
  }

  private static ITxObject GetObjectFromApiObj(ITApiObj apiObj)
  {
    string str = (string) null;
    apiObj.DumpToString(ref str);
    ITxObject objectFromApiObj = (ITxObject) null;
    if (str != null)
      objectFromApiObj = TxConvertor.tID2Object(str);
    return objectFromApiObj;
  }
}
